package action.AZ10;

import java.util.ArrayList;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import services.AZ10.AZ10Services;
import com.util.Component;
import com.PublicSystem;
import com.util.Util;
import com.syslog.SysLogServices;
/**
 * 制卡批次相关操作
 * @author duy
 * 
 */
@Controller
@RequestMapping("AZ10.do")
public class AZ10Action {
	PublicSystem sys = PublicSystem.getInstance();
	AZ10Services ss = new AZ10Services();
	SysLogServices log = SysLogServices.getInstance();
	/**
	* 查询批次信息
	* @author duy
	* @param request
	* @param response
	* @throws Exception
	*/ 
	@RequestMapping(params = "method=getAZ10")
	public void getAZ10(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String key = Component.getQuest("key", request);
		String key1 = Component.getQuest("key1", request);
		String key2 = Component.getQuest("key2", request);
		String key3 = Component.getQuest("key3", request);
	    HashMap parms = sys.getGridSort(request);
	    String json = Util.Encode(ss.getAZ10(new Object[] {key, key1, key2, key3}, parms));
	    Component.print(json, response);
	    String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
		HashMap obj = new HashMap();
	    if(null == json || "" == json) {
			obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", userid);    //操作人
			obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "用户" + userid + "查询" + "制卡批次为" + key + "的批次信息");  //日志内容，自己组合拼装
			obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", userid);    //输入参数
			obj.put("dataout", "ERROR");  //输出参数
			log.sysLogMap(obj, request);
	    } else {
	    	obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", userid);    //操作人
			obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "用户" + userid + "查询" + "制卡批次为" + key + "的批次信息");  //日志内容，自己组合拼装
			obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", userid);    //输入参数
			obj.put("dataout", "SUCCESS");//输出参数
			log.sysLogMap(obj, request);
	    }
	}
	/**
	 * 新增制卡批次人员信息
	 * @author duy 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=saveAZ10")
	public void saveAZ10(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String json = request.getParameter("data");
		String userid = Component.getSession("userid", request);
		ArrayList rows = (ArrayList)Util.Decode(json);
		HashMap row = (HashMap)rows.get(0);
		row.put("aae300", userid);
		String aaz001 = (String) row.get("aaz001");
		Component.print(ss.insertAZ10(row), response);
		//日志接口=====================MAP方式	
		String rwid = Component.getSession("rwid", request);
		HashMap obj = new HashMap();
		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
		obj.put("log_type", "T02");   //日志类别，见sys_log_bm
		obj.put("userid", userid);    //操作人
		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空,不为空则自定义
		obj.put("content", "用户" + userid + "新增" + "制卡批次为" + aaz001 + "的批次信息");  //日志内容，自己组合拼装
		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", userid);    //输入参数
		obj.put("dataout", "用户" + userid + "新增" + "制卡批次为" + aaz001 + "的批次信息");//输出参数
		log.sysLogMap(obj, request);
	}
	/**
	 * 获取人员信息
	 * @author duy 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getAZ10Data")
	public void getAZ10Data(HttpServletRequest request, HttpServletResponse response) throws Exception {
		HashMap user = ss.getAZ10Data(Component.getQuest("id", request));
    	Component.print(Util.Encode(user), response);
    	String json = Util.Encode(user);
    	String aaz001 = Component.getQuest("id", request);
		String userid = Component.getSession("userid", request);
       	String rwid = Component.getSession("rwid", request);
   		HashMap obj = new HashMap();
    	if(null == json || "" == json) {
       		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
       		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
       		obj.put("userid", userid);    //操作人
      		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
       		obj.put("content", "用户" + userid + "查询" + "制卡批次为" + aaz001 + "的批次信息");  //日志内容，自己组合拼装
       		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
       		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
       		obj.put("datain", userid);    //输入参数
       		obj.put("dataout", "ERROR");//输出参数
      		log.sysLogMap(obj, request);
    	} else {
       		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
       		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
       		obj.put("userid", userid);    //操作人
      		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
       		obj.put("content", "用户" + userid + "查询" + "制卡批次为" + aaz001 + "的批次信息");  //日志内容，自己组合拼装
       		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
       		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
       		obj.put("datain", userid);    //输入参数
       		obj.put("dataout", "SUCCESS");//输出参数
      		log.sysLogMap(obj, request);
    	}
	}
	/**
	 * 终止制卡批次人员信息
	 * @author duy 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=endAZ10")
	public void endAZ10(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String json = request.getParameter("data");
		String userid = Component.getSession("userid", request);
		ArrayList rows = (ArrayList)Util.Decode(json);
		HashMap row = (HashMap)rows.get(0);
		row.put("aaz705", userid);
		Component.print(ss.endAZ10(row), response);
		String aaz001 = (String) row.get("aaz001");		
		String rwid = Component.getSession("rwid", request);
		HashMap obj = new HashMap();
		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
		obj.put("log_type", "T03");   //日志类别，见sys_log_bm
		obj.put("userid", userid);    //操作人
		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
		obj.put("content", "用户" + userid + "终止" + "批次号为" + aaz001 + "的批次信息");  //日志内容，自己组合拼装
		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", userid);    //输入参数
		obj.put("dataout", "用户" + userid + "终止" + "批次号为" + aaz001 + "的批次信息");//输出参数
		log.sysLogMap(obj, request);
	}
}